package com.mconnect.msurvey.controller;

import java.util.ArrayList;
import java.util.List;

public class ExportManager {
	
	public List<String> getQueryList(String campName){
		List<String> queryList = new ArrayList<String>();
		
		String query1 = "CREATE TABLE `Outbound`.`" + campName +"_camp` " +
				"( `camp_id` int(11) NOT NULL AUTO_INCREMENT, " +
				"`camp_data_ins` datetime NOT NULL, `camp_surname` varchar(50) COLLATE utf8_polish_ci DEFAULT NULL, " +
				"`camp_name` varchar(45) COLLATE utf8_polish_ci DEFAULT NULL, " +
				"`camp_firm_name` varchar(250) COLLATE utf8_polish_ci DEFAULT NULL, " +
				"`camp_adress` varchar(250) COLLATE utf8_polish_ci DEFAULT NULL, " +
				"`camp_city` varchar(100) COLLATE utf8_polish_ci DEFAULT NULL, " +
				"`camp_post_code` varchar(6) COLLATE utf8_polish_ci DEFAULT NULL, " +
				"`camp_region` varchar(250) COLLATE utf8_polish_ci DEFAULT NULL, " +
				"`camp_tel1` varchar(9) COLLATE utf8_polish_ci DEFAULT NULL, " +
				"`camp_tel2` varchar(9) COLLATE utf8_polish_ci DEFAULT NULL, " +
				"`camp_tel3` varchar(9) COLLATE utf8_polish_ci DEFAULT NULL, " +
				"`camp_x1` varchar(250) COLLATE utf8_polish_ci DEFAULT NULL, " +
				"`camp_x2` varchar(250) COLLATE utf8_polish_ci DEFAULT NULL, " +
				"`camp_x3` varchar(250) COLLATE utf8_polish_ci DEFAULT NULL, " +
				"`camp_x4` varchar(250) COLLATE utf8_polish_ci DEFAULT NULL, " +
				"`camp_x5` varchar(250) COLLATE utf8_polish_ci DEFAULT NULL, " +
				"`camp_x6` varchar(250) COLLATE utf8_polish_ci DEFAULT NULL, " +
				"`camp_x7` varchar(250) COLLATE utf8_polish_ci DEFAULT NULL, " +
				"`camp_x8` varchar(250) COLLATE utf8_polish_ci DEFAULT NULL, " +
				"`camp_x9` varchar(250) COLLATE utf8_polish_ci DEFAULT NULL, " +
				"`camp_x10` varchar(250) COLLATE utf8_polish_ci DEFAULT NULL, " +
				"PRIMARY KEY (`camp_id`)) " +
				"ENGINE=MyISAM AUTO_INCREMENT=5020 DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci$$";
		
		queryList.add(query1);
		
		String query2 = "CREATE " +
				"DEFINER=`outboundUser`@`%` " +
				"TRIGGER `Outbound`.`addResultCode_" + campName +"` " +
				"AFTER INSERT ON `Outbound`.`" + campName +"_camp` " +
				"FOR EACH ROW " +
				"BEGIN INSERT INTO `Outbound`.`" + campName +"_result` (`res_camp_id`,`res_result`,`res_status`,`res_user`,`res_date`,`res_callback_user`,`res_callback_date`,`res_callback_tel_num`,`res_count`,`res_uniqueid`) " +
				"select camp_id, 0, 1, '', now(), '', now(), '', 0, '' from " + campName +"_camp where camp_id not in(select res_camp_id from " + campName +"_result);  END " +
				"$$";
		
		queryList.add(query2);
		
		return queryList;
	}

}
